﻿function temp_convert() {
    var temp, lemp;
    temp = prompt("Insert the tempature to convert to fahrenheit");

    temp = ((temp - 32) * 5) / 9;
    alert("the tempature is " + temp + "\u00B0" + " celcius");
}

function degree_convert() {
    var rad, degree, rad2degree, degree2rad;
    rad2degree = confirm("Do you want to convert radians to degrees?")
    if (!rad2degree)
        degree2rad = confirm("Do you want to convert degrees to radians?")
    if (rad2degree == true) {
        rad = prompt("How many radians?")
        degree = rad * 180 / (Math.PI);
        alert(rad + " radians = " + degree + " degrees");
    }
    if (degree2rad == true) {
        degree = prompt("How many degrees?")
        rad = degree * (Math.PI) / 180;
        alert(degree + " degreees = " + rad + " radians");
    }
}

function coin_flip() {
    var coin_head;
        coin_head = Math.floor( Math.random() * (1 + 1) );
        alert("Clink!");
        if (coin_head == 1) {
            return true
        }
        else
            return false
    }

function dice_roll(dice_sides) {
    var continues = true;
    while (continues == true) {
        continues = confirm(Math.floor(Math.random() * (dice_sides)) + 1);
    }

}

function num_greater() {
    var num1, num2;
    num1 = prompt("What is the first number?");
    num2 = prompt("What is the second number?")
    alert("The greater number is " + greater(num1, num2));
}

function greater(var1, var2) {
    var var_greater;

    if (var2 > var1) {
        var_greater = var2;
    }
    if (var1 > var2) {
        var_greater = var1;
    }
    return var_greater;
}

function num_lesser() {
    var num1, num2;
    num1 = prompt("What is the first number?");
    num2 = prompt("What is the second number?")
    alert("The lower number is " + lesser(num1, num2));
}

function lesser(var1, var2) {
    var var_lesser;
    
    if (var1 > var2) {
        var_lesser = var2;
    }
    if (var2 > var1) {
        var_lesser = var1;
    }
    return var_lesser;
}

function num_adder8() {
    var num1, num2, adder_eight;
    num1 = prompt("What is the first number?");
    num2 = prompt("What is the second number?")
    adder_eight = adder8(num1, num2);
    alert("The sume of the numbers \"between\" " + num1 + " <--> " + num2 + " = " + adder_eight);
}

function adder8(num1, num2) {
    var num_low, num_greater, num_total = 0;
    if (num1 > num2) {
        num_greater = num1;
        num_low = num2;
    }
    if (num1 < num2) {
        num_greater = num2 ;
        num_low = num1;
    }
    for(num_greater; num_greater >= num_low; num_greater--) {
        num_total = Number(num_total) + Number(num_greater);
    }
    return num_total;
}

function num_adder9() {
    var num1, num2, adder_nine;
    num1 = prompt("What is the first number?");
    num2 = prompt("What is the second number?");
    adder_nine = adder9(num1, num2);
    alert("The sume of the numbers \"between\" " + num1 + " <--> " + num2 + " = " + adder_nine);
}

function adder9(num1, num2) {
    var num_low, num_greater, num_total = 0;
    if (num1 != num2) {

        if (num1 > num2) {
            num_greater = num1;
            num_low = num2;
        }
        if (num1 < num2) {
            num_greater = num2;
            num_low = num1;
        }
    }
    else {
        return num1;
    }
    for (num_greater; num_greater >= num_low; num_greater--) {
        num_total = Number(num_total) + Number(num_greater);
    }
    return num_total;
}

function give_random() {
    var num1, num2, amount;
    num1 = prompt("What is the minimum number?");
    num2 = prompt("What is the maximum number?");
    amount = prompt("How Many alerts do you want?")
    for (amount; amount > 0; amount--) {
        alert("The Random Number is " + getRandomInt(num1, num2));
    }
}

function getRandomInt(min, max) {
    return Math.floor(Math.random() * (max - min + 1)) + Number(min);
}

function overflow1(var1) {
    var flow;
    flow = var1 + var1;
    return overflow2(flow);
}

function overflow2(var2) {
    var flowed;
    flowed = var2 + var2;
    return overflow1(flowed);
}

function guessed_number() {
    var num1, random_number, game = 0;
    random_number = Math.floor(Math.random() * (100 - 1 + 1)) + Number(1);
    while (game != 1) {
        num1 = prompt("Guess a number between 1 and 100?");
        game = guess_number(num1,random_number);
    }
}

function guess_number(var1,rand) {
        if (var1 != rand) {
            if (var1 > rand) {
                alert("The number is lower then that");
            }
            if (var1 < rand) {
                alert("The number is higher then that");
            }
        }
        else {
            alert("Correct! " + var1 + " is the right number! \n You Win So Many Kudos!");
            return 1;
        }
}